<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttbl' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

        <form:form commandName="afterSale" class="layui-form" id="form">

            <input type="hidden" name="_method" value="PUT"/>

            <div class="layui-form-item">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='shjg' /></label>
                <div class="layui-input-inline" style="width:70%;">
                    <input type="radio" name="checkStatus" lay-filter="checkStatus" lay-verify="required" value="2" title="<fmt:message key='shtg' />" <c:if test="${afterSale.checkStatus eq 3}">checked="checked"</c:if>/>
                    <input type="radio" name="checkStatus" lay-filter="checkStatus" lay-verify="required" value="3" title="<fmt:message key='shbtg' />" <c:if test="${afterSale.checkStatus eq 4}">checked="checked"</c:if>/>
                </div>
            </div>

            <div class="layui-form-item feijin-success" style="display:none;">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='shlxr' /></label>
                <div class="layui-input-inline">
                    <form:input path="consignee" class="layui-input"/>
                </div>
            </div>

            <div class="layui-form-item feijin-success" style="display:none;">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='shdh' /></label>
                <div class="layui-input-inline">
                    <form:input path="consigneeMobile" class="layui-input"/>
                </div>
            </div>

            <div class="layui-form-item feijin-success" style="display:none;">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='shouhdz' /></label>
                <div class="layui-input-inline">
                    <form:textarea path="consigneeAddress" class="layui-textarea" style="height:100px;width:100%"/>
                </div>
            </div>

            <div class="layui-form-item feijin-fail" style="display:none;">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='jjyy' /></label>
                <div class="layui-input-inline">
                    <form:textarea path="reason" class="layui-textarea" style="height:100px;width:100%"/>
                </div>
            </div>

            <div class="layui-input-block">
                <div style="display: none"><input type="button" value="保存" class="layui-btn" id="submit" lay-filter="submit" lay-submit></div>
            </div>

        </form:form>
    </div>
</div>

<script>

    $(function () {

        layui.use(['form', 'laydate'], function () {

            var form = layui.form;
            var laydate = layui.laydate;

            form.on('radio(checkStatus)', function (data) {
                var id = data.value;

                if (id == 2) {
                    $(".feijin-success").show();
                    $(".feijin-fail").hide();
                }

                if (id == 3) {
                    $(".feijin-success").hide();
                    $(".feijin-fail").show();
                }

            });

            form.on('submit(submit)', function (data) {

                var checkStatus = $(":radio[name='checkStatus']:checked").val();

                if(!checkStatus) {
                    layer.msg("<fmt:message key='qxzshzt' />");
                    return false;
                }

                if (checkStatus == 2) {
                    if(!$("#consignee").val() || !$("#consigneeMobile").val() || !$("#consigneeAddress").val()) {
                        layer.msg("<fmt:message key='qtxshxx' />");
                        return false;
                    }
                }

                if (checkStatus == 3) {
                    if(!$("#reason").val()) {
                        layer.msg("<fmt:message key='qtxjjyy' />");
                        return false;
                    }
                }


                $("#form").ajaxSubmit({
                    success: function (result) {
                        if (result.status) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            parent.$("#search").click();
                        } else {
                            layui.use('layer', function () {
                                layer.msg(result.message);
                            });
                        }
                    }
                });
            });

        });

    });
</script>
</body>
</fmt:bundle>
</html>